VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Cls_Utili_Ayudas"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Dim Col As TrueOleDBGrid80.Column
Dim cols As TrueOleDBGrid80.Columns
Public Enum enmControlTipo
    TDBGrid = 0
    ComboBox = 1
End Enum

Public Sub Buscar_TruedbGrilla(dc As Adodc, Nombre As TrueOleDBGrid80.TDBGrid)
On Error GoTo ErrHandler
    Dim c As Integer
    With Nombre
        Set cols = .Columns
        c = .Col
       .HoldFields
       dc.Recordset.Filter = GetFilter()
       .Col = c
       .EditActive = True
     End With
     Exit Sub
ErrHandler:
    MsgBox Err.Source & ":" & vbCrLf & Err.Description
End Sub

Public Function GetFilter() As String
    Dim tmp As String
    Dim N As Integer
    For Each Col In cols
        If Trim(Col.FilterText) <> "" Then
            N = N + 1
            If N > 1 Then
                tmp = tmp & " AND "
            End If
            tmp = tmp & Col.DataField & " LIKE '" & Col.FilterText & "*'"
        End If
    Next Col
    GetFilter = tmp
End Function

Public Sub Limpia_Controls(F As Form, Clase As String)
On Error GoTo Mensaje
    Dim Nc As Integer, i As Integer
    Nc = F.Controls.Count - 1
    For i = 0 To Nc
        If (TypeName(F.Controls(i)) = Clase) Then
            F.Controls(i).Text = ""
        End If
    Next i
    Exit Sub
Mensaje:
    MsgBox Err.Description, vbInformation + vbCritical
End Sub

Public Sub BackColores_Controls(F As Form, Clase As String, xtColor As String)
On Error GoTo Mensaje
    Dim Nc As Integer, i As Integer
    Nc = F.Controls.Count - 1
    For i = 0 To Nc
        If (TypeName(F.Controls(i)) = Clase) Then
            F.Controls(i).BackColor = xtColor
        End If
    Next i
    Exit Sub
Mensaje:
    MsgBox Err.Description, vbInformation + vbCritical
End Sub

Public Sub Habilitar_Controles(F As Form, Clase As String, Valor As Boolean)
On Error GoTo Mensaje
    Dim Nc As Integer, i As Integer
    Nc = F.Controls.Count - 1
    For i = 0 To Nc
        If (TypeName(F.Controls(i)) = Clase) Then
            F.Controls(i).Enabled = Valor
        End If
    Next i
    Exit Sub
Mensaje:
    MsgBox Err.Description, vbInformation + vbCritical
End Sub

Public Sub Hablilita_Grilla(F As Form, xcol As Integer, Valor As Boolean)
On Error GoTo Mio
    Dim i As Integer
    For i = 0 To xcol
        F.tblDetalle.Columns(i).Locked = Valor
    Next i
    Exit Sub
Mio:
   MsgBox Err.Description
End Sub

Public Sub Ftab(intTecla As Integer)
    On Error GoTo ControlError
        If intTecla = 13 Or intTecla = 40 Then
            SendKeys ("{tab}")
            Exit Sub
        End If
        If intTecla = 38 Then SendKeys ("+{tab}")
    Exit Sub
ControlError:
End Sub

Public Sub Pintar_Check_Flex(Flex As VSFlexGrid, ctFila As Integer, ctColum As Integer, ctDesde As Integer, ctHasta As Integer)
On Error GoTo ErrRango
  Dim i As Integer, ii, intFila, intFilaP, r
  With Flex
        If .Cell(flexcpChecked, ctFila, ctColum) = flexChecked Then
            intFilaP = ctDesde
            For ii = ctDesde To ctHasta
                .Col = intFilaP
                .CellBackColor = &HFFE1C4    '&H80FF&
                intFilaP = intFilaP + 1
            Next
        Else
            intFilaP = ctDesde
            For ii = ctDesde To ctHasta
                .Col = intFilaP
                .CellBackColor = vbWhite
                intFilaP = intFilaP + 1
            Next
        End If
  End With
  Exit Sub
ErrRango:
  MsgBox Err.Description, vbInformation
End Sub

Public Sub LimpiarFiltro(Grilla As TrueOleDBGrid80.TDBGrid)
    For Each Col In Grilla.Columns
        Col.FilterText = ""
    Next Col
End Sub

Public Sub UbicaDropDown(nFila, nCol, ctGrilla As TrueOleDBGrid80.TDBGrid, F As Form)
    ctGrilla.Top = F.tblDetalle.RowTop(nFila) + (F.tblDetalle.Top + 230)
    ctGrilla.Left = F.tblDetalle.Columns(nCol).Left + 50
End Sub

Public Sub MuestraBotones(F As Form)
    
    F.cmdNew.Visible = True
    F.cmdModify.Visible = True
    F.cmdDelete.Visible = True
    F.cmdHelp(0).Enabled = False
    F.cmdUpdate.Visible = False
    F.cmdAddDelDetail_Det(0).Visible = False
    F.cmdAddDelDetail_Det(1).Visible = False
    F.tblDetalle.AllowAddNew = False
    F.tblDetalle.AllowUpdate = False
    For x = 0 To 3
        F.cmdMove(x).Visible = True
    Next x
    Call BackColores_Controls(F, "TextBox", &H8000000F)
    Call Habilitar_Controles(F, "Frame", False)
    Call Habilitar_Controles(F, "TextBox", False)
    F.tblDetalle.HighlightRowStyle.BackColor = &H808080
    F.tblDetalle.HighlightRowStyle.ForeColor = &HFFFFFF
    F.tblDetalle.MarqueeStyle = dbgHighlightRowRaiseCell
End Sub

Public Sub OcultaBotones(F As Form)
    F.cmdNew.Visible = False
    F.cmdModify.Visible = False
    F.cmdDelete.Visible = False
    
    F.cmdHelp(0).Enabled = True
    F.cmdUpdate.Visible = True
    F.cmdAddDelDetail_Det(0).Visible = True
    F.cmdAddDelDetail_Det(1).Visible = True
    For x = 0 To 3
        F.cmdMove(x).Visible = False
    Next x
    Call BackColores_Controls(F, "TextBox", &HFFFFFF)
    Call Habilitar_Controles(F, "TextBox", True)
    Call Habilitar_Controles(F, "Frame", True)
    F.tblDetalle.MarqueeStyle = dbgFloatingEditor
    
End Sub

Public Sub Grilla_KeyCode(F As Form, ctColumn As Integer, Tecla As String)
Select Case Tecla
    Case "112"
        Dim ctColu As Integer
        ctColu = F.tblDetalle.Col
        If ctColu = 0 Then
            F.tblDetalle_ButtonClick (0)
        ElseIf ctColu = 1 Then
            F.tblDetalle_ButtonClick (1)
        ElseIf ctColu = 2 Then
            F.tblDetalle_ButtonClick (2)
        ElseIf ctColu = 4 Then
            F.tblDetalle_ButtonClick (4)
        ElseIf ctColu = 13 Then
            F.tblDetalle_ButtonClick (13)
        End If
    Case "45"
        Call F.cmdAddDelDetail_Det_Click(0)
    Case "vbKeyF11"
        Call F.cmdAddDelDetail_Det_Click(1)
End Select
End Sub

Public Sub AgreDelItem(F As Form, ctIndex As Integer, ctEtiqueta As String)
On Error GoTo Mio
    If ctEtiqueta = "A" Or ctEtiqueta = "M" Then
        If ctIndex = 0 Then
            Rs_DetalleDocu.AddNew
            F.tblDetalle.Col = 1
        Else
            If Rs_DetalleDocu.RecordCount > 0 Then
                Rs_DetalleDocu.Delete adAffectCurrent
                If Rs_DetalleDocu.RecordCount > 0 Then Rs_DetalleDocu.MoveFirst
                F.tblDetalle.Refresh
            End If
        End If
        F.tblDetalle.SetFocus
    End If
    Exit Sub
Mio:
    MsgBox Err.Description, vbInformation
End Sub

Public Sub Tecla_Dow(NroTecla As String, F As Form)
Select Case NroTecla
    Case "114"
        F.cmdNew_Click
    Case "115"
        F.cmdDelete_Click
    Case "116"
        F.cmdModify_Click
End Select
End Sub

